<template>
  <div class="index" id="matchindex" v-loading="loading">
    <div class="searchBox">
      <input type="search" name="" v-model="req.keywords" placeholder="请输入需要搜索的内容" />
      <el-button type="primary" @click="search" class="searchBtn" icon="el-icon-search"
        >搜索</el-button
      >
      <!-- <div class="searchBtn">
        <i class="van-icon van-icon-search" style="color: white; font-size: 20px" icon="el-icon-search"></i>
      </div> -->
    </div>
    <div class="content">
      <p class="noresult" v-if="list.length == 0">暂无结果</p>
      <div class="searchResult">
        <ul class="result">
          <li class="resultList" v-for="(item,i) in list" :key="i" @click="togNav('/policyDetails?id='+item.id)">
            <p class="resultTitle">
              {{item.title}}
            </p>
            <p class="resultTime">{{item.updateTime1}}</p>
          </li>
        </ul>
    </div>
    </div>
    
  </div>
</template>
<script>
import { findAllList } from "@/api/service/service";
import { Notification, MessageBox, Message } from "element-ui";
export default {
  name: "policymobile",
  data: function () {
    return {
      req: {
        limit: 100,
        page: 1,
        keywords: "",
      },
      list: [],
      loading: false, // 滚动加载中
    };
  },
  mounted() {

    
  },
  watch: {},

  methods: {
    togNav(e) {
      this.$router.push(e);
    },
    findRecommendPolicyListApi() {
      this.loading = true;
        findAllList(this.req).then((res) => {
          this.loading = false;
          if (res.code === 0) {
            for(let i=0; i<res.data.length; i++){
                    res.data[i].updateTime1 = this.renderTime(res.data[i].createTime)
             }
            this.list = res.data;
            console.log(this.list);
          }
        });
    },
    renderTime(date) {
      let datea = date.split(/[- : \/]/)
      console.log(datea[0]+datea[1]+datea[2])
      return datea[0]+'年'+datea[1]+'月'+datea[2].slice(0,2)+"日"
    },
    getScroll(event) {
      console.log(e);
    },
    search(){
      if(this.req.keywords){
        this.findRecommendPolicyListApi();
      }else{
        Message("搜索不能为空");
      }
      
    }
  },
};
</script>
<style scoped>
.index {
  background: #fff;
}
#matchindex {
  overflow-x: hidden;
}
#matchindex .searchBox {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  box-shadow: 1px 2px 1px rgba(0, 0, 0, 0.15);
  display: -ms-flexbox;
  display: flex;
  -ms-flex-pack: start;
  justify-content: flex-start;
  -ms-flex-align: center;
  align-items: center;
}
#matchindex .searchBox input {
  border: none;
  outline: none;
  height: 40px;
  padding: 5px 15px;
  box-sizing: border-box;
  font-size: 14px;
  color: #333;
  -ms-flex: 1;
  flex: 1;
}
#matchindex .searchBtn {
  width: 100px;
  height: 40px;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-pack: center;
  justify-content: center;
  -ms-flex-align: center;
  align-items: center;
  border: 0;
  background: linear-gradient(90deg, #0bbf76, #3ab8c4);
}
.van-icon,
.van-icon:before {
  display: inline-block;
}
.van-icon {
  position: relative;
  font: 14px/1 vant-icon;
  font-size: inherit;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
}
.van-icon,
.van-icon:before {
  display: inline-block;
}
.content {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px;
}
#matchindex .noresult {
    width: 100%;
    height: 60px;
    line-height: 60px;
    font-size: 14px;
    color: #999;
    text-align: center;
}
#matchindex .content {
    width: 100%;
    padding: 10px 15px;
    box-sizing: border-box;
}
#matchindex .result {
    padding: 15px 0;
    box-sizing: border-box;
}
#matchindex .resultList {
    width: 100%;
    padding: 5px 0;
    border-bottom: 1px solid #ccc;
}
#matchindex .resultTitle {
    margin-bottom: 10px;
    color: #333;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-height: 22px;
}
#matchindex .resultTime {
    font-size: 12px;
    color: #999;
}
</style>
